#include<iostream>

using namespace std;

const int N = 1e6 + 10;
typedef long long ll;
ll a[N];

int main()
{
	ll n, m; cin >> n >> m;
	ll Min = 0x3f3f3f3f3f3f3f3f, Max = -1;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i]; 
		Min = min(Min, a[i]);
		Max = max(Max, a[i]);
	}
	ll left = Min, right = Max;
	while (left < right)
	{
		ll lenth = 0;

		ll mid = left + (right - left+1) / 2;

		for (int i = 1; i <= n; i++)
		{
			if (a[i] > mid)
			{
				lenth += (a[i] - mid);
			}
		}
		
		if (lenth < m)
		{
			right = mid-1;
		}
		else
		{
			left = mid;
		}
	}
	cout << left;
	return 0;
}
